/*案例：
现在需要提供大中小3个型号的画笔，能够绘制5种不同的颜色，如果采用蜡笔，就要提供3 x 5 = 15支蜡笔

如果使用毛笔，就只需要提供大中小3支毛笔和5个颜料盒，用3 + 5 = 8 个类就可以完成
*/

#include<iostream>
#include<memory>
#include<string>
#include<windows.h>
class Color
{
public:
    virtual std::string getColor()const= 0;
    virtual ~Color()= default;
};

class Red:public Color
{
    private:
        std::string color_;
    public:
    Red():color_("红色"){};
    std::string getColor()const override{return color_;};
};

class Blue:public Color
{
    private:
        std::string color_;
    public:
    Blue():color_("蓝色"){};
    std::string getColor()const override{return color_;};
};

class Green:public Color
{
    private:
        std::string color_;
    public:
    Green():color_("绿色"){};
    std::string getColor()const override{return color_;};
};


class Pen
{
    protected:
        std::shared_ptr<Color>color_;
    public:
        virtual void setColor(std::shared_ptr<Color> color){color_ = color;};
        virtual  void draw(std::string)const{};
};

class BigPen:public Pen
{
    public:
        void draw(std::string name){std::cout << "大号毛笔绘制" << color_->getColor() << name << std::endl;};
};
class MiddlePen:public Pen
{
    public:
        void draw(std::string name){std::cout << "中号毛笔绘制" << color_->getColor() << name << std::endl;};
};
class SmallPen:public Pen
{
    public:
        void draw(std::string name){std::cout << "小号毛笔绘制" << color_->getColor() << name << std::endl;};
};



int main(int argc, char const *argv[])
{
    SetConsoleOutputCP(CP_UTF8);
    auto pen = std::make_shared<MiddlePen>();
    auto color = std::make_shared<Red>();
    pen->setColor(color);
    pen->draw("苹果");
    return 0;
}
